package com.zxmc.server.mapper;

import com.zxmc.aop.AutoFill;
import com.zxmc.enumeration.OperationType;
import com.zxmc.pojo.dto.UserLoginDto;
import com.zxmc.pojo.entity.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface UserMapper {
    @Select("select * from user where username=#{username}")
    User list(UserLoginDto userLoginDto);

    @AutoFill(OperationType.INSERT)
    @Insert("insert into user (username, password, created_at,avatar) values (#{username},#{password},#{createdAt},#{avatar});")
    void insert(User user);

    @Select("select * from user where id=#{userId}")
    User listById(Integer userId);


    void update(User user);

    @Delete("delete from user where id=#{id}")
    void delete(User user);

    @Select("select * from user")
    List<User> listAll();
}
